#@layout() #define main()
<div class="xp-layout">
	<form id="roleForm" action="xpRole/add" method="post" class="layui-form layui-form-pane">
		<input type="hidden" id="state" name="role.state" value="1">
		<div class="layui-form-item">
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">角色名称</label>
				<div class="layui-input-block">
					<input type="text" name="role.name" value="#(role.name??)" lay-verify="required" autocomplete="off" placeholder="请输入角色名称" maxlength="50" class="layui-input">
				</div>
			</div>
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">说明</label>
				<div class="layui-input-block">
					<input type="text" name="role.bz" value="#(role.bz??)" lay-verify="" autocomplete="off" placeholder="请输入角色说明" maxlength="200" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div style="text-align: center;">
				<button class="layui-btn" lay-submit="" lay-filter="go">立即提交</button>
			</div>
		</div>
	</form>
	<script type="text/javascript">
		layui.use([ 'form', 'laydate' ], function() {
			var form = layui.form, layer = layui.layer, laydate = layui.laydate;

			//监听提交
			form.on('submit(go)', function(data) {
				var url = $('#roleForm').attr('action');
				$.post(url, data.field, function(res) {
					if (res.result == 1) {
						layer.open({
							type : 2,
							title : '编辑角色权限',
							area : [ '60%', '60%' ],
							shade : 0,
							maxmin : true,
							id : 'roleRight_iframe',
							content : 'xpRole/right_ui?ID=' + res.ID,
							btn : [ '提交', '关闭' ],
							yes : function(index, layero) {
								var iframeWin = window[layero.find('iframe')[0]['name']];
								iframeWin.saveRight();
							},
							btn2 : function(index, layero) {
							},
							zIndex : layer.zIndex,
							success : function(layero) {
								layer.setTop(layero);
							}
						});
					} else {
						layer.msg(res.msg, {
							icon : 5
						});
					}
				});
				return false;
			});
		});
	</script>
</div>
#end

